package collection;

public class generic1 {

    public static void main(String[] args) {
        Animal<String> animal = new Animal<>();
        animal.setFunc("aa");

        Dog<Integer> d1 = new Dog<>();
//        d1.setFunc(1);
    }

}

class Animal<T>{

    private T name;

    public T getName() {
        return name;
    }

    public void setName(T name) {
        this.name = name;
    }

    public void setFunc(T v){
        System.out.println(v);
    }
}

//父的E要和子的E一样
class Dog<E> {

}
class Horse extends Animal<Integer>{

    public Integer riding(){
        return super.getName();
    }
}

//子类不是泛型，父类是泛型，父类赋值类型，不赋值的话，默认是Object
class Cat {
//    @Override
//    public void setFunc(String v) {
//        super.setFunc(v);
//    }
}